Skip to content

Add specification-drvien test suite#69

Open
patch0 wants to merge 11 commits intomainfrom
test-against-specs
Open

Add specification-drvien test suite#69
patch0 wants to merge 11 commits intomainfrom
test-against-specs

Conversation

@patch0
Copy link
Copy Markdown
Contributor

@patch0 patch0 commented May 1, 2026

What's changed

Spec-driven test suite

Adds a formal spec document and test runner so the Ruby renderer can be validated against canonical examples.

  • spec/kramdown_rpf-legacy-spec.md — the legacy spec for kramdown-rpf, covering all supported block types (hint, hints, task, challenge, code, collapse, save, new-page, no-print, print-only, quiz, knowledge quiz, microbit, scratch). Each example shows the markdown input and expected HTML output, separated by a · middle dot. The spec is also published in the documentation repo as the canonical human-readable reference.

  • spec/specification_spec.rb — RSpec suite that parses the spec at load time and generates nested describe/context/it blocks, one per example. Runs via SPEC_MD=spec/kramdown_rpf-legacy-spec.md bundle exec rake spec. The SPEC_MD env var defaults to the local spec path so CI requires no extra setup.

CI

  • .github/workflows/ci.yml — spec tests are now run as part of the test job, using the spec bundled in this repo. Previously the job attempted to curl the spec from the private documentation repo (which required a PAT); the spec is now versioned here directly.

README

  • Added a Testing against the spec section documenting how to run the spec tests and noting that spec/kramdown_rpf-legacy-spec.md must be kept in sync with the copy in the documentation repo when examples change.

Test results

I've marked the legacy test blocks as "skip".

202 examples, 0 failures, 30 skipped

@patch0 patch0 marked this pull request as ready for review May 1, 2026 16:11
Copilot AI review requested due to automatic review settings May 1, 2026 16:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a markdown “legacy spec” document and wires RSpec up to execute all spec examples as tests, replacing the existing example-file conversion suite.

Changes:

  • Add spec/kramdown_rpf-legacy-spec.md and a parser-driven RSpec suite to run each ```example block as a test.
  • Add an HTML structural matcher + diff output helper in spec_helper.
  • Skip the old examples/-based conversion tests and update CI/README to run against the spec file.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
spec/specification_spec.rb New spec runner that parses the spec markdown and generates RSpec examples.
spec/spec_helper.rb Adds HTML comparison matcher/diff utilities and shared Kramdown options.
spec/kramdown_rpf_spec.rb Reorders conversion fixtures and skips the conversion suite in favor of spec-driven tests.
spec/kramdown_rpf-legacy-spec.md Adds the formal legacy specification (inputs + expected HTML).
spec/i18n_spec.rb Uses an around hook to restore locale after each locale context.
README.md Documents running the spec-based tests and overriding the spec file via SPEC_MD.
Gemfile Adds new dev dependencies for spec-based HTML comparison.
.github/workflows/ci.yml Sets SPEC_MD in CI when running specs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/specification_spec.rb Outdated
Comment thread spec/specification_spec.rb Outdated
Comment thread spec/specification_spec.rb Outdated
Comment thread Gemfile
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment on lines +155 to +156
**If you add or change examples in `examples/`, you must update the spec file accordingly** — both here in `spec/kramdown_rpf-v0-spec.md` and in the canonical copy in the [documentation repository](https://github.com/RaspberryPiFoundation/documentation) at `docs/technology/codebases-and-products/raspberry-flavoured-markdown/kramdown_rpf-legacy-spec.md`.

@patch0 patch0 changed the title Add specification spec Add specification-drvien test suite May 1, 2026
patch0 and others added 3 commits May 1, 2026 17:20
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants